<?php
declare (strict_types=1);

namespace app\admin\logic\finance;

use app\admin\model\finance\Split as SplitModel;
use app\admin\model\finance\SplitCourse;
use app\admin\model\finance\SplitFlow;

/**
 * 分成后台管理逻辑
 */
class Split extends SplitModel
{
    /**
     * 分成明细
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-08-19
     */
    public function getList($map)
    {
        return app(SplitCourse::class)
            ->with([
                'user_name',
                'course_title',
                'section_title',
                'school_name',
                'school_user',
                'teacher_user',
                'share_user',
                'primary_user',
                'secondary_user'
            ])
            ->where($map)
            ->order('update_time', 'DESC')
            ->paginate($this->getListRows());

    }

    /**
     * 分成明细
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-08-19
     */
    public function getUserList($map)
    {

        return $this
            ->with([
                'user_name',
                'school_name',
                'superior_user'
            ])
            ->where($map)
            ->order('update_time', 'DESC')
            ->paginate($this->getListRows());

    }

    /**
     * 分成流水
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-08-19
     */
    public function getUserFlow($user_id)
    {

        return app(SplitFlow::class)
            ->with([
                'user_name',
            ])
            ->where('user_id', $user_id)
            ->order('create_time', 'DESC')
            // ->buildSql();
            ->paginate($this->getListRows());

    }

}
